#!/bin/bash

# 建议证书路径/IP/证书有效日期都以参数形式传入


ES_HOME="$ELASTICSEARCH_HOME"

export ES_PATH_CONF="/opt/edp/${service.serviceName}/conf"


/usr/bin/expect -d >/dev/null 2>&1 <<EOF
set time 120
spawn sh /home/elasticsearch/elasticsearch/bin/elasticsearch-setup-passwords interactive
expect "Please confirm that you would like*"
send "y\n"
expect "Enter password for*"
send "${conf['es_password']}\n"
expect "Reenter password for*"
send "${conf['es_password']}\n"
expect "Enter password for*"
send "${conf['es_password']}\n"
expect "Reenter password for*"
send "${conf['es_password']}\n"
expect "Enter password for*"
send "${conf['es_password']}\n"
expect "Reenter password for*"
send "${conf['es_password']}\n"
expect "Enter password for*"
send "${conf['es_password']}\n"
expect "Reenter password for*"
send "${conf['es_password']}\n"
expect "Enter password for*"
send "${conf['es_password']}\n"
expect "Reenter password for*"
send "${conf['es_password']}\n"
expect "Enter password for*"
send "${conf['es_password']}\n"
expect "Reenter password for*"
send "${conf['es_password']}\n"
expect eof
EOF